package com.exp2.exp2;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

public class NewListen {
    @Component
    static class NewListener implements ApplicationListener<ApplicationEvent> {
        private static final Logger logger = LoggerFactory.getLogger(NewListen.class);

        @Override
        public void onApplicationEvent(ApplicationEvent applicationEvent) {
            //System.out.println("监听测试");
            logger.info("事件监听器获取到 ApplicationEvent 睡眠当前线程2.5秒...");

            try {
                Thread.sleep(2500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            logger.info("ApplicationEvent 的 message 属性是 :{}", applicationEvent.getSource());

        }
    }
}

